import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsNumber, IsOptional, IsString, MaxLength } from "class-validator";
import { PhotoMetadata } from "libs/db/entity/photoMetadata.entity";

export class CreatePhotoDto {

  @ApiProperty({
    example: 'haha',
    description: '名字',
    required: true
  })
  @IsString()
  name: string;


  @ApiProperty({
    example: '我是 一条说明, 最大长度为 2',
    description: '最大长度为 2',
    required: true
  })
  @MaxLength(2, { always: true, message: _ => `${_.targetName} 中的 ${_.property} 最大长度 应为 ${_.constraints[0]}` })
  @IsString()
  description: string;

  @ApiProperty({
    example: 'hahah',
    description: '文件名字 ',
    required: false
  })
  @IsString()
  filename: string;


  @ApiProperty({
    example: 1,
    description: '文件大小 ',
  })
  @IsNumber()
  views?: number;

  @ApiProperty({
    example: true,
    description: '是否公开 ',
  })
  @IsBoolean()
  @IsOptional()
  isPublished ?: boolean;

  @ApiProperty({
    description: '照片信息对象 -> 是否有具有**关联对象**取决于**查询query**',
    required: false,
    type: [PhotoMetadata]
  })
  // @ValidateNested()
  @IsNumber()
  @IsOptional()
  metadata: PhotoMetadata;
}